/*    Copyright 2010 Tobias Marschall
 *
 *    This file is part of MoSDi.
 *
 *    MoSDi is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    MoSDi is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with MoSDi.  If not, see <http://www.gnu.org/licenses/>.
 */

package mosdi.paa;

import mosdi.fa.CharacterAutomaton;

/** A deterministic arithmetic automaton. */ 
public abstract class DAA implements CharacterAutomaton {

	@Override
	public abstract int getAlphabetSize();
	@Override
	public abstract int getStartState();
	@Override
	public abstract int getStateCount();
	@Override
	public abstract int getTransitionTarget(int state, int character);
	public abstract int getEmission(int state);
	public abstract int getEmissionCount();
	public abstract int getStartValue();
	public abstract int getValueCount(); 
	public abstract int performOperation(int state, int value, int emission); 

	public int computeValue(int[] sequence) {
		int state = getStartState();
		int value = getStartValue();
		for (int c : sequence) {
			state = getTransitionTarget(state,c);
			value = performOperation(state, value, getEmission(state));
		}
		return value;
	}

	/** Returns the operation if it can be cast into a SimpleOperation, otherwise returns null. */
	public SimpleOperation getOperation() { return null; }
	
}
